import request from '@/utils/http.js'

// 保存属性
export const saveAttrInfoApi = (data) => {
  return request({
    url: 'pms/backend/attr/save',
    method: "POST",
    data: JSON.stringify(data),
  })
}

// 获取属性列表
export const getAttrListApi = ({ pageNum, pageSize, name, type, categoryId } = params) => {
  return request({
    url: 'pms/backend/attr/list',
    method: "GET",
    params: {
      pageNum,
      pageSize,
      name,
      type,
      categoryId,
    }
  })
}

// 根据id获取属性信息
export const getAttrInfoApi = (id) => {
  return request({
    url: `pms/backend/attr/info/${id}`,
    method: "GET",
  })
}

// 修改属性信息
export const updateAttrInfoApi = (data) => {
  return request({
    url: 'pms/backend/attr/update',
    method: "PUT",
    data: JSON.stringify(data),
  })
}

// 根据分类id获取对应属性
export const getAttrsByCategoryIdApi = (categoryId, type) => {
  return request({
    url: 'pms/backend/attr/attrList',
    method: "GET",
    params: {
      categoryId,
      type,
    }
  })
}

// 删除属性
export const deleteAttrApi = (ids) => {
  return request({
    url: 'pms/backend/attr/delete',
    method: "DELETE",
    data: JSON.stringify(ids),
  })
}